package cn.glc.daily.life.web.convert;

import cn.glc.daily.life.infrastructure.po.UserInfoPo;
import cn.glc.daily.life.model.dto.UserSignupDto;
import cn.simon.free.tools.utils.DateUtils;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * 用户基础信息转换类
 *
 * @author simon
 * @date 2020/9/21 13:27
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
@Mapper
public interface UserInfoConvert {
    UserInfoConvert INSTANCE = Mappers.getMapper(UserInfoConvert.class);

    /**
     * 用户注册对象转用户基本信息
     *
     * @param userSignupDto
     * @param uid
     * @return
     */
    default UserInfoPo userSignupDtoToUserInfo(UserSignupDto userSignupDto, long uid) {
        UserInfoPo userInfoPo = new UserInfoPo();
        userInfoPo.setUid(uid);
        userInfoPo.setNickName(userSignupDto.getNickName());
        userInfoPo.setCreateTime(DateUtils.now());
        return userInfoPo;
    }
}
